import { defineStore } from 'pinia'
import { getUserDeviceInfo } from './helps'

export const useSystemInfo = defineStore({
  id: 'system',
  state: () => {
    return {
      systemInfo: {
        statusBarHeight: 0,
        navBarHeight: 0,
      },
    }
  },
  actions: {
    setSystemInfo() {
      const info =  getUserDeviceInfo()
      let systemInfo = {
        ...info.systemInfo,
        navBarHeight: info.customBar
      }
      Object.assign(this, { systemInfo })
    //   this.systemInfo = systemInfo
    //   this.systemInfo.statusBarHeight = systemInfo.statusBarHeight
    //   this.navBarHeight = customBar
    },
  },
  getters: {
    statusBarHeight: (state:any) => {
      return state.systemInfo.statusBarHeight
    },
    navBarHeight: (state:any) => {
      return state.systemInfo.navBarHeight
    },
    getSystemInfo: (state:any) => {
      return state.systemInfo
    },
  },
})
